<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="javascript:;">会议审核列表</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="post" action="{:url('AdminMeeting/meetingAuditList')}">
        时间:
        <input type="text" class="form-control js-bootstrap-datetime" name="start_time"
               value="{$search['start_time']|default=''}"
               style="width: 140px;" autocomplete="off">-
        <input type="text" class="form-control js-bootstrap-datetime" name="end_time"
               value="{$search['end_time']|default=''}"
               style="width: 140px;" autocomplete="off"> &nbsp; &nbsp;
        类型:
        <select class="form-control" name="keys" style="width: 140px;">
            <option value='vm_title' <if condition="$search['keys'] eq 'vm_title'">selected="selected"</if>>主题</option>
            <option value='user_id' <if condition="$search['keys'] eq 'user_id'">selected="selected"</if>>发起者</option>
            <option value='category' <if condition="$search['keys'] eq 'category'">selected="selected"</if>>分类</option>
            <option value='compere' <if condition="$search['keys'] eq 'compere'">selected="selected"</if>>主持人</option>
        </select> &nbsp;&nbsp;
        关键字:
        <input type="text" class="form-control" name="keyword" style="width: 200px;"
               value="{$search['keyword']|default=''}" placeholder="请输入关键字...">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('AdminMeeting/meetingAuditList')}">清空</a>
    </form>
    <form class="js-ajax-form" action="" method="post">
        <div class="table-actions">
            <a class="btn btn-danger btn-sm meetingDelete">批量删除</a>
            <a class="btn btn-primary btn-sm meetingAuditFail">批量审核不通过</a>
            <a class="btn btn-primary btn-sm meetingAuditPass">批量审核通过</a>
        </div>
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="15">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th width="50">ID</th>
                <th>发起者</th>
                <th>主题</th>
                <th width="100">封面图片</th>
                <th>分类</th>
                <th>主持人</th>
                <th width="85">参会人员</th>
                <th>参会方式</th>
                <th width="90">开始时间</th>
                <th width="85">会议回放</th>
                <th width="50">时长</th>
                <th width="100">状态</th>
                <th width="50">公开</th>
                <th>操作</th>
            </tr>
            </thead>
            <empty name="meetingList['list']">
                <td style="text-align:center" colspan="15">无数据</td>
            </empty>
            <foreach name="meetingList['list']" item="vo">
                <tr>
                    <td>
                        <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                               value="{$vo.id}" title="ID:{$vo.id}">
                    </td>
                    <td>{$vo.id}</td>
                    <td>{$vo.staff_name}</td>
                    <td>{$vo.vm_title}</td>
                    <td>
                        <a href="javascript:parent.imagePreviewDialog('{$vo['cover_pic']}');">
                            <!-- <i class="fa fa-photo fa-fw"></i> -->
                            <img height="50" src="{$vo['cover_pic']}"/>
                        </a>
                    </td>
                    <td>{$vo.name}</td>
                    <td>{$vo.compere_name}</td>
                    <td>
                        <a href="javascript:;" onclick="confereeLook('{$vo.id}', '{$vo.vm_title}');">点击查看</a>
                    </td>
                    <td>
                        <if condition="in_array($vo['join_way'], [1,3])">
                            <a data-toggle="tooltip" title="{$vo.address}" onclick="addressLook('{$vo['address']}', '{$vo.vm_title}')">{:joinWay()[$vo['join_way']]}</a>
                        <else />
                            {:joinWay()[$vo['join_way']]}
                        </if>
                    </td>
                    <td>{$vo.start_time}</td>
                    <td>
                        <notempty name="vo.store_link">
                            <a href="javascript:;" onclick="liveLook('{$vo.id}', '{$vo.vm_title}');">点击查看</a>
                            <else/>
                            <i class="fa fa-close"></i>
                        </notempty>
                    </td>
                    <td>{$vo.duration}</td>
                    <td>{$meetingStatus[$vo['status']]}</td>
                    <td>
                        <notempty name="vo.is_open">
                            <a data-toggle="tooltip" title="已公开"><i class="fa fa-check"></i></a>
                            <else/>
                            <a data-toggle="tooltip" title="未公开"><i class="fa fa-close"></i></a>
                        </notempty>
                    </td>
                    <td>
                        <if condition="$vo['status'] eq 1">
                            <a class="btn btn-success btn-sm" style="margin:1px;" href="{:url('AdminMeeting/meetingAudit',array('id'=>$vo['id']))}">审核</a>
                        </if>
                        <a class="btn btn-default btn-sm" style="margin:1px;" href="javascript:parent.openIframeLayer('{:url('AdminMeeting/meetingDetails',array('id'=>$vo['id']))}',' {$vo.vm_title} -详情',{});">查看详情</a>
                        <if condition="$vo['is_detele'] eq 0">
                            <a class="btn btn-danger btn-sm" style="margin:1px;" onclick="meetingDeleteOne({$vo['id']})">{:lang('DELETE')}</a>
                        </if>
                    </td>
                </tr>
            </foreach>
            <tfoot>
            <tr>
                <th width="15">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th width="50">ID</th>
                <th>发起者</th>
                <th>主题</th>
                <th width="100">封面图片</th>
                <th>分类</th>
                <th>主持人</th>
                <th width="85">参会人员</th>
                <th>参会方式</th>
                <th width="90">开始时间</th>
                <th width="85">会议回放</th>
                <th width="50">时长</th>
                <th width="100">状态</th>
                <th width="50">公开</th>
                <th>操作</th>
            </tr>
            </tfoot>
        </table>
        <div class="table-actions">
            <a class="btn btn-danger btn-sm meetingDelete">批量删除</a>
            <a class="btn btn-primary btn-sm meetingAuditFail">批量审核不通过</a>
            <a class="btn btn-primary btn-sm meetingAuditPass">批量审核通过</a>
        </div>
        <ul class="pagination">{$meetingList['page']|default=''}<li class="page item"><a class="page link" href="#">总数：{$meetingList['count']}条</a></li></ul>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>

    // 查看参会人员
    function confereeLook(vm_id, vm_title) {
        openIframeLayer("{:url('AdminMeeting/confereeLook')}?vm_id=" + vm_id, vm_title+'-参会人员名单', {
            area: ['700px', '550px'],
            btn: ['关闭'],
        });
    }

    // 查看会议地址
    function addressLook(address, vm_title) {
        openIframeLayer("{:url('AdminMeeting/addressLook')}?address=" + address, vm_title+'-会议地址', {
            area: ['850px', '550px'],
        });
    }
    // 会议回放
    function liveLook(vm_id, vm_title) {
        openIframeLayer("{:url('AdminMeeting/liveLook')}?vm_id=" + vm_id, vm_title+'-会议回放', {
            area: ['850px', '550px'],
        });
    }

    function reloadPage(win) {
        win.location.reload();
    }

    // 批量删除
    $('.meetingDelete').on('click', function () {
        var ids = [];
        $("input[name='ids[]']").each(function () {
            if ($(this).is(':checked')) {
                ids.push($(this).val());
            }
        });

        if (ids.length) {
            art.dialog({
                id: 'warning',
                title: '提示',
                icon: 'warning',
                content: '确定删除吗？',
                cancelVal: '关闭',
                ok: function () {
                   meetingDelete(ids)
                }
            });
        } else {
           art.dialog({
                content: '请至少选择一项',
                icon: 'warning',
                title: '提示',
                ok: function () {
                    this.title('请至少选择一项');
                    return true;
                }
            }); 
        }
    });

    // 单个删除
    function meetingDeleteOne(id){
        art.dialog({
            id: 'warning',
            icon: 'warning',
            title: '提示',
            content: '确定删除吗？',
            cancelVal: '关闭',
            ok: function () {
               meetingDelete([id])
            }
        });
    }

    // 执行删除
    function meetingDelete(data){
        $.ajax({
            url: "{:url('AdminMeeting/meetingDelete')}",
            dataType: 'json',
            data: {id:data},
            type: "POST",
            success: function(data){
                if (data.code == '1') {
                    noty({
                        text: data.msg,
                        type: 'success',
                        layout: 'topCenter',
                        modal: true,
                        timeout: 800,
                        callback: {
                            afterClose: function () {
                                if (data.url) {
                                    //返回带跳转地址
                                    // window.location.href = data.url;
                                    history.go(0) // 当前页面刷新
                                } else {
                                    //刷新当前页
                                    reloadPage(window);
                                }
                            }
                        }
                    }).show();
                } else if (data.code == '0') {
                    art.dialog({
                        content: data.msg,
                        icon: 'warning',
                        title: '提示',
                        ok: function () {
                            this.title(data.msg);
                            return true;
                        }
                    });
                }
            }
        });
    }

    // 批量审核通过
    $('.meetingAuditPass').on('click', function () {
        var ids = [];
        $("input[name='ids[]']").each(function () {
            if ($(this).is(':checked')) {
                ids.push($(this).val());
            }
        });

        if (ids.length) {
             art.dialog({
                title: "提示",
                content: "正在执行批量审核，请谨慎操作！",        
                icon: "warning",
                lock: true,//是否锁定屏幕，默认是false
                fixed: true,//静止在浏览器某个地方不动，不受滚动条拖动影响
                time: 3,//如果有cancel方法的话会调用cancel方法
                okVal: "审核通过",
                ok: function () { 
                    var data = {'id':ids,'status':2}
                    submitAudit(data)
                },
                cancelVal: "取消",
                cancel: function () {
                }
            });
        } else {
           art.dialog({
                content: '请至少选择一项',
                icon: 'warning',
                title: '提示',
                ok: function () {
                    this.title('请至少选择一项');
                    return true;
                }
            }); 
        }
    });

    // 批量审核不通过
    $('.meetingAuditFail').on('click', function () {
        var ids = [];
        $("input[name='ids[]']").each(function () {
            if ($(this).is(':checked')) {
                ids.push($(this).val());
            }
        });

        if (ids.length) {
             art.dialog({
                title: "提示",
                content: "正在执行批量审核，请谨慎操作！",        
                icon: "warning",
                lock: true,//是否锁定屏幕，默认是false
                fixed: true,//静止在浏览器某个地方不动，不受滚动条拖动影响
                time: 3,//如果有cancel方法的话会调用cancel方法
                okVal: "审核不通过",
                ok: function () { 
                    var data = {'id':ids,'status':3}
                    submitAudit(data)
                },
                cancelVal: "取消",
                cancel: function () {
                }
            });
        } else {
           art.dialog({
                content: '请至少选择一项',
                icon: 'warning',
                title: '提示',
                ok: function () {
                    this.title('请至少选择一项');
                    return true;
                }
            }); 
        }
    });

    // 提交审核
    function submitAudit(data){
        $.ajax({
            url: "{:url('AdminMeeting/meetingAudit')}",
            dataType: 'json',
            data: data,
            type: "POST",
            success: function(data){
                if (data.code == '1') {
                    noty({
                        text: data.msg,
                        type: 'success',
                        layout: 'topCenter',
                        modal: true,
                        timeout: 800,
                        callback: {
                            afterClose: function () {
                                if (data.url) {
                                    //返回带跳转地址
                                    window.location.href = data.url;
                                    // history.go(0) // 当前页面刷新
                                } else {
                                    //刷新当前页
                                    reloadPage(window);
                                }
                            }
                        }
                    }).show();
                } else if (data.code == '0') {
                    art.dialog({
                        content: data.msg,
                        icon: 'warning',
                        ok: function () {
                            this.title(data.msg);
                            return true;
                        }
                    });
                }
            }
        });
    }
</script>
</body>
</html>